-- 1.02 - Check to make sure we are operating under MacOS 8.0 or above set vrs to version of application "Finder" if (vrs does not start with "8.1") and (vrs does not start with "8.0") then display dialog  "This script requires system 8.0 or higher." buttons {"OK"} default button {"OK"} return end if -- 1.02 - Check to make sure Portfolio is running tell application "Finder" set P_app to every process whose name contains "Portfolio" if P_app is {} then display dialog  "Portfolio must be running for this script to operate." buttons {"OK"} default button {"OK"} return end if end tell tell application "Portfolio" -- Go to Portfolio and find out how many items are selected in the current gallery. set theCount to count every record of selection of front gallery -- If no items are selected, we need to ask the user to select something and then quit. if theCount = 0 then display dialog  "Please select one or more items in the gallery and rerun the command." buttons {"OK"} default button {"OK"} return end if --Get the path of the first record in the selection set pth to path of first record of the selection of front gallery end tell -- 1.01 - Parse Portfolio's path if it is up on a server to strip the server name. if pth starts with "::" then set the text item delimiters to {":"} set argCnt to (the count of text items in pth) set pth to (text items 4 through argCnt in (pth)) as string end if -- Determine whether the original file exists. If it does not, display an error and quit. tell application "Finder" if not (exists file pth) then display dialog "Could not find the original file. Try updating the Portfolio record." buttons {"OK"} return end if -- 1.01: Get the file type to determine whether it is acceptable -- We'll accept jpeg, gif, and pict. set fType to file type of file pth if {"JPEG", "GIFf", "PICT"} does not contain fType then display dialog "This file type will not work with Desktop Pictures. You must use a PICT, JPEG, or GIF." buttons {"OK"} return end if end tell -- Find out how the user wants the image displayed. Desktop Pictures actually allows for 5 settings, -- but only three buttons are allowed in the standard dialog. set theResult to display dialog "Choose how to display this image:" buttons {"Tiled", "Centered", "Scaled"} default button {"Centered"} set chooseButton to the button returned of theResult -- Use Desktop Pictures control panel to set the picture, based on the display choice. tell application "Desktop Pictures" if chooseButton = "Tiled" then set desktop picture to (pth as alias) positioning tiled else if chooseButton = "Centered" then set desktop picture to (pth as alias) positioning centered else if chooseButton = "Scaled" then set desktop picture to (pth as alias) positioning scaled else if chooseButton = "Filling Screen" then set desktop picture to (pth as alias) positioning filling screen end if quit end tell